package com.hbyj.struts.action;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;


import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

import com.hbyj.db.function.DbTools;
import com.hbyj.hbm.vo.Jbqk01;
import com.hbyj.hbm.vo.Jbqk01Id;
import com.hbyj.hbm.vo.YjczYjcz12;
import com.hbyj.util.Constants;
import com.hbyj.util.PageClass;
import com.opensymphony.xwork2.ActionSupport;

public class ZskAction extends ActionSupport{
	private String jsonResult;
	private int total;
	private List rows = new ArrayList();
	
	public String getJsonResult() {
		return jsonResult;
	}
	public void setJsonResult(String jsonResult) {
		this.jsonResult = jsonResult;
	}
	
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public List getRows() {
		return rows;
	}
	public void setRows(List rows) {
		this.rows = rows;
	}

	public String queryZsk(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String pageNo = request.getParameter("page");
		int pageSize = Constants.PAGE_KEY;
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String name = request.getParameter("name");//查询类型 yapp表示在预案匹配模块中查询
		String syly = request.getParameter("syly");
		String conStr = "";
		if(!"".equals(startTime)){
			conStr += "and zzkx01030 >='"+startTime+"' ";
		}
		if(!"".equals(endTime)){
			conStr += "and zzkx01030 <='"+endTime+"'";
		}
		if(!"".equals(name)){
			name = "%"+name+"%";
			conStr += "and zzkx01010 like '"+name+"'";
		}
		if(!"".equals(syly)){
			conStr +="and zzkx01060 = '"+syly+"'";
		}
		if(!"".equals(conStr)){
			conStr = conStr.substring(4);
			conStr = " where "+conStr;
		}
		String hql = "from YjczZzkx01"+conStr;
		String countHql = "select count(*) from YJCZ_ZZKX01 "+conStr;

		int t = DbTools.getDataSQLCount(countHql);
		PageClass page = new PageClass();
		page.setPageShow(pageSize);  //设置每页显示的行数
		page.setPageCount(t);  //设置总页数
		page.setCurrentPage(Integer.parseInt(pageNo));  //设置当前页
		int first=page.getNextIndex(); //获得开始的索引值
		int max=page.getPageShow();  //获得每次显示的值
		rows = (List)DbTools.findPageHQL(first, max,hql);
		total = t;
		return SUCCESS;
	}
}